home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_11_05
/
test_obj
/
dgen.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-20
|
35KB
|
1,254 lines
/*
AnaGram Parsing Engine
Copyright (c) 1992, Jerome T. Holland.
All Rights Reserved.
*/
/* Line 39, D:\C_USR_J\DISTRIB\DGEN.SYN */
#include "tutils.h"
#include "dgen.h"
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define RULE_CONTEXT (&((PCB).cs[(PCB).ssx]))
#define ERROR_CONTEXT ((PCB).cs[(PCB).error_frame_ssx])
#define CONTEXT ((PCB).cs[(PCB).ssx])
#ifndef NEAR
#define NEAR near
#endif
#ifndef LOCUS
#define LOCUS near
#endif
#ifndef VOID
#define VOID void
#endif
#ifndef CONST
#define CONST const
#endif
#ifndef CONVERT_CASE(c)
#define CONVERT_CASE(c) (c)
#endif
#ifndef TAB_SPACING
#define TAB_SPACING 8
#endif
#define AG_INIT_PARSE() VOID init_dgen(VOID)
#define AG_PARSE() VOID dgen(VOID)
#define AG_INITIALIZE() init_dgen()
#define AG_PARSER_STACK_SIZE 32
dgen_pcb_type dgen_pcb;
#define PCB dgen_pcb
#ifndef DGEN_H
#include "dgen.h"
#endif
static char * NEAR ag_rp_1(VOID) {
/* Line 63 */
return release();
}
static VOID NEAR ag_rp_2(int c) {
/* Line 65 */
collectFirst(c);
}
static VOID NEAR ag_rp_3(int c) {
/* Line 67 */
collect(c);
}
static VOID NEAR ag_rp_4(int c) {
/* Line 68 */
collect(c);
}
static char * NEAR ag_rp_5(VOID) {
/* Line 71 */
return release();
}
static VOID NEAR ag_rp_6(int c) {
/* Line 73 */
collectFirst(c);
}
static VOID NEAR ag_rp_7(int c) {
/* Line 75 */
collect(c);
}
static char * NEAR ag_rp_8(VOID) {
/* Line 83 */
collect('}');return(release());
}
static VOID NEAR ag_rp_9(VOID) {
/* Line 85 */
collectFirst('{');
}
static VOID NEAR ag_rp_10(int c) {
/* Line 87 */
collect(c);
}
static VOID NEAR ag_rp_11(VOID) {
/* Line 91 */
collect('}');
}
static VOID NEAR ag_rp_12(VOID) {
/* Line 93 */
collect('{');
}
static struct STRLIST * NEAR ag_rp_13(char * s) {
/* Line 95 */
return listNew(s,"");
}
static struct STRLIST * NEAR ag_rp_14(struct STRLIST * lst, char * s) {
/* Line 96 */
return listAdd(lst,s,"");
}
static char * NEAR ag_rp_15(VOID) {
/* Line 99 */
return release();
}
static VOID NEAR ag_rp_16(int c) {
/* Line 101 */
collectFirst(c);
}
static VOID NEAR ag_rp_17(int c) {
/* Line 103 */
collect(c);
}
static VOID NEAR ag_rp_18(VOID) {
/* Line 107 */
writeDriver();
}
static VOID NEAR ag_rp_19(char * eb) {
/* Line 116 */
addBlock(eb);
}
static VOID NEAR ag_rp_20(char * n) {
/* Line 130 */
setRunName(n);
}
static VOID NEAR ag_rp_21(struct STRLIST * vl, char * b) {
/* Line 133 */
makeVary(vl,b);
}
static VOID NEAR ag_rp_22(struct STRLIST * vl, char * b) {
/* Line 135 */
makeComb(vl,b);
}
static struct STRLIST * NEAR ag_rp_23(char * v) {
/* Line 137 */
return listNew(v,"");
}
static struct STRLIST * NEAR ag_rp_24(struct STRLIST * lst, char * v) {
/* Line 139 */
return listAdd(lst,v,"");
}
static VOID NEAR ag_rp_25(struct STRLIST * vl, struct STRLIST * il) {
/* Line 160 */
addTVars(vl,"char","char",il);
}
static VOID NEAR ag_rp_26(struct STRLIST * vl, struct STRLIST * il) {
/* Line 169 */
addTVars(vl,"char *","char *",il);
}
static VOID NEAR ag_rp_27(struct STRLIST * vl, struct STRLIST * il) {
/* Line 178 */
addTVars(vl,"int","int",il);
}
static VOID NEAR ag_rp_28(struct STRLIST * vl, struct STRLIST * il) {
/* Line 187 */
addTVars(vl,"double","double&",il);
}
static VOID NEAR ag_rp_29(struct STRLIST * vl, struct STRLIST * il) {
/* Line 196 */
addTVars(vl,"FILE *","FILE *",il);
}
static VOID NEAR ag_rp_30(struct STRLIST * vl, struct STRLIST * il) {
/* Line 207 */
addTVars(vl,"INTARR2","INTARR2",il);
}
static VOID NEAR ag_rp_31(struct STRLIST * vl, struct STRLIST * il) {
/* Line 216 */
addTVars(vl,"Item","Item&",il);
}
static VOID NEAR ag_rp_32(struct STRLIST * vl, struct STRLIST * il) {
/* Line 224 */
addTVars(vl,"Client","Client&",il);
}
static VOID NEAR ag_rp_33(struct STRLIST * vl, struct STRLIST * il) {
/* Line 232 */
addTVars(vl,"Invoice","Invoice&",il);
}
#define AG_TRACE_ERROR
#define AG_VT dgen_pcb_type
#define AG_COUNT_RULE(k)
static dgen_vs_type ag_null_value;
#define AG_INPUT_TYPE int
#define AG_TOKEN_TYPE dgen_token_type
#define AG_VALUE_STACK_TYPE dgen_vs_type
#define AG_INPUT_VALUE CONVERT_CASE(*PCB.lab)
#define AG_INPUT_CODE (*PCB.lab)
#define V(i,t) (*(t *) (&(PCB).vs[(PCB).ssx + i]))
#define VS(i) (PCB).vs[(PCB).ssx + i]
#ifndef AG_GET_VALUE
#define AG_GET_VALUE AG_INPUT = AG_INPUT_VALUE
#endif
#ifndef GET_CONTEXT
#define GET_CONTEXT CONTEXT = (PCB).input_context
#endif
#ifndef AG_NULL
#define AG_NULL (PCB).vs[(PCB).ssx] = ag_null_value
#endif
#ifdef AG_CONTEXT_TYPE
#define AG_SAVE_CONTEXT {GET_CONTEXT;}
#define AG_SWAP_CONTEXT(k1,k2) (PCB).cs[k1] = (PCB).cs[k2]
#endif
#ifndef AG_SAVE_CONTEXT
#define AG_SAVE_CONTEXT
#define AG_SWAP_CONTEXT(k1,k2)
#endif
typedef enum {
ag_shift_accept,
ag_go_to,
ag_shift_reduce,
ag_shift_simple_reduce,
ag_reduce_form,
ag_simple_reduce,
ag_accept,
ag_syn_error,
ag_null_go_to,
ag_skip,
ag_skip_reduce,
ag_recover
} ag_parser_action;
static int ag_ap;
#define AG_VALUE
#define AG_INPUT (*(int *) &PCB.vs[PCB.ssx])
static CONST unsigned char ag_rpx[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7,
0, 0, 0, 0, 8, 9, 10, 0, 11, 12, 13, 14, 0, 0, 0, 0, 15, 16,
17, 0, 0, 18, 0, 0, 0, 19, 0, 20, 21, 22, 23, 24, 0, 0, 0, 0,
0, 0, 0, 0, 0, 25, 26, 27, 28, 29, 30, 31, 32, 33
};
static unsigned char ag_key_itt[] = {
0
};
static unsigned short ag_key_pt[] = {
0
};
#define AG_KEY
static unsigned char ag_key_ch[] = {
0,110,116,255, 97,255,116,255,110,255, 47, 67, 70, 73, 99,100,105,114,
115,255,110,116,255, 97,255,116,255,110,255, 47, 67, 70, 73, 99,100,105,
114,115,125,255,110,116,255, 97,255,116,255,110,255, 67, 70, 73, 99,100,
105,114,115,255, 47,255, 47, 99,118,255,123,255, 47,123,255,125,255, 47,
125,255
};
static unsigned char ag_key_act[] = {
0,3,3,4,3,4,1,4,2,4,3,3,3,2,3,3,2,3,3,4,3,3,4,3,4,1,4,2,4,3,3,3,2,3,3,
2,3,3,0,4,3,3,4,3,4,1,4,2,4,3,3,2,3,3,2,3,3,4,3,4,3,3,3,4,0,4,3,0,4,0,
4,3,0,4
};
static unsigned char ag_key_parm[] = {
0, 69, 67, 0, 66, 0, 63, 0, 0, 0, 5, 68, 65, 0, 59, 64, 0, 46,
62, 0, 69, 67, 0, 66, 0, 63, 0, 0, 0, 5, 68, 65, 0, 59, 64, 0,
46, 62, 61, 0, 69, 67, 0, 66, 0, 63, 0, 0, 0, 68, 65, 0, 59, 64,
0, 46, 62, 0, 5, 0, 5, 49, 47, 0, 60, 0, 5, 60, 0, 61, 0, 5,
61, 0
};
static unsigned char ag_key_jmp[] = {
0, 12, 18, 0, 31, 0, 4, 0, 6, 0, 0, 2, 8, 1, 21, 25, 8, 35,
42, 0, 60, 66, 0, 79, 0, 23, 0, 25, 0, 48, 50, 56, 20, 69, 73, 27,
83, 90, 0, 0,106,112, 0,125, 0, 43, 0, 45, 0, 96,102, 40,115,119,
47,129,136, 0,142, 0,144,146,155, 0, 0, 0,162, 0, 0, 0, 0,164,
0, 0
};
static unsigned char ag_key_index[] = {
10, 0, 29, 49, 0, 0, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 0, 58,
10, 10, 10, 49, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 0, 0, 0, 60,
58, 58, 64, 64, 64, 64, 64, 64, 64, 64, 64, 0, 0, 58, 58, 58, 66, 58,
58, 58, 58, 58, 58, 58, 58, 58, 58, 0, 58, 58, 0, 66, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 69, 69, 69, 69, 69, 69, 69, 69, 69, 0, 71
};
static unsigned char ag_key_ends[] = {
47,0, 108,105,101,110,116,0, 73,76,69,0, 118,111,105,99,101,0,
101,109,0, 104,97,114,0, 111,117,98,108,101,0, 114,114,50,0,
117,110,116,101,115,116,0, 116,114,105,110,103,0, 47,0,
108,105,101,110,116,0, 73,76,69,0, 118,111,105,99,101,0, 101,109,0,
104,97,114,0, 111,117,98,108,101,0, 114,114,50,0,
117,110,116,101,115,116,0, 116,114,105,110,103,0, 108,105,101,110,116,0,
73,76,69,0, 118,111,105,99,101,0, 101,109,0, 104,97,114,0,
111,117,98,108,101,0, 114,114,50,0, 117,110,116,101,115,116,0,
116,114,105,110,103,0, 47,0, 47,0, 111,109,98,105,110,105,110,103,0,
97,114,121,105,110,103,0, 47,0, 47,0,
};
#define AG_TCV(x) (((int)(x) >= -1 && (int)(x) <= 255)